package com.yanqu.road.server.cmd.activity.hotpotjump;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HotpotJumpProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.jumppot.HotpotJumpModule;
import com.yanqu.road.server.protocol.GameProtocol;

@CmdApi(reqMsg = HotpotJumpProto.HotpotJumpLvUpSkillChooseReqMsg.class, respMsg = HotpotJumpProto.HotpotJumpLvUpSkillChooseRespMsg.class)
@Cmd(code = GameProtocol.S_HOTPOT_JUMP_LV_UP_SKILL_CHOOSE, desc = "升级技能选择")
public class HotpotJumpLvUpSkillChooseCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HotpotJumpProto.HotpotJumpLvUpSkillChooseReqMsg reqMsg = HotpotJumpProto.HotpotJumpLvUpSkillChooseReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(HotpotJumpModule.class).skillChoose(reqMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret > 0) {
            //获得注解的code
            int code = this.getClass().getAnnotation(Cmd.class).code();
            int backClientProtocol = code % 10000;
            player.sendPacket(backClientProtocol, HotpotJumpProto.HotpotJumpStartGameRespMsg.newBuilder().setRet(ret));
        }
    }
}
